<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="_path" value="${pageContext.request.contextPath}"></c:set>
<!-- 验证还是jquery-validation好用，这里省事没用 -->
<form id="resourcesForm" method="post" style="margin: 10;text-align: center;">
	<input type="hidden" name="resouceid" value="${resource.resouceid }">
	<input type="hidden" name="delflg" value="${resource.delflg }">
	<input type="hidden" name="creatuserid" value="${resource.creatuserid }">
	<input type="hidden" name="enable" value="${resource.enable }">
	<input type="hidden" name="idpath" value="${resource.idpath }">
	<table>
		<tr>
			<td>父资源：</td>
			<td><input id="_presourceid" name="parentid" value="${resource.parentid }" style="width: 400">
			</td>
		</tr>
		<tr>
			<td>名字：</td>
			<td><input name="name" value='${resource.name }' style="width: 400"
				 class="easyui-validatebox" required="true">
			</td>
		</tr>
		<tr>
			<td>URL：</td>
			<td><input name="url" value='${resource.url }' style="width: 400" >
		</tr>
		<tr>
			<td>type：</td>
			<td>
				<select name="type" style="width: 400">
					<option value="url" ${resource.type == "url"?"selected":"" }>url</option>
					<option value="button" ${resource.type == "button"?"selected":"" }>button</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>图标：</td>
			<td>
				<input name="icon" value='${resource.icon }' style="width: 400" >
			</td>
		</tr>
		<tr>
			<td>排序号：</td>
			<td>
				<input name="ordernum" value='${resource.ordernum }' style="width: 400" required="true"  class="easyui-numberbox">
			</td>
		</tr>
	</table>
	<a href="#" id="btn-back" onclick="closeWindow();" class="easyui-linkbutton" iconCls="icon-back">返回</a>
	<a href="#" id="btn-add" onclick="addOrUpdateResources();" class="easyui-linkbutton" iconCls="icon-save">保存</a>
</form>
<script>
$('#_presourceid').combotree({
	url : '${_path }/resources/queryList${resource.resouceid == null ? "":"?ignId="}${resource.resouceid}'
});
function addOrUpdateResources(){
	var r = $('#resourcesForm').form('validate');
	if(!r) {
		return false;
	}
	$.post('resources/resources${resource.resouceid == null ? "Add" : "Update"}',$("#resourcesForm").serializeArray(),function(data){
		$('#MyPopWindow').window('close');
		$('#resourceTable').treegrid('reload');  
		$.messager.alert('提示',data.mes,'info');
	});
};
</script>